
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <title>JJencode编码/JJencode解码</title>
  <style type="text/css">
	 .layui-elem-field{
		 border-color: #e6e6e6;
		 border-width: 1px 0 0;
		     padding: 0;
			 border-style: solid;
	 }
	 fieldset {
	     display: block;
	     margin-inline-start: 2px;
	     margin-inline-end: 2px;
	     padding-block-start: 0.35em;
	     padding-inline-start: 0.75em;
	     padding-inline-end: 0.75em;
	     padding-block-end: 0.625em;
	     min-inline-size: min-content;
	     border-width: 2px;
	     border-style: groove;
	     border-color: threedface;
	     border-image: initial;
	 }
	 .layui-textarea{
		height: 250px;
		min-height: 100px;
		padding: 6px 10px;
		resize: vertical;
		color: #393D49;
		display: block;
		width: 100%;
		line-height: 20px;
		position: relative;
		border-width: 1px;
		border-style: solid;
		background-color: #fff;
		border-radius: 2px;
		border-color: #e6e6e6;
		outline: 0;
		-webkit-appearance: none;
		transition: all .3s;
		-webkit-transition: all .3s;
		box-sizing: border-box;
		font-family: inherit;
		font-size: inherit;
		font-style: inherit;
		font-weight: inherit;
		-webkit-tap-highlight-color: rgba(0,0,0,0);
		}
	 textarea {
	     -webkit-writing-mode: horizontal-tb !important;
	     text-rendering: auto;
	     color: -internal-light-dark(black, white);
	     letter-spacing: normal;
	     word-spacing: normal;
	     text-transform: none;
	     text-indent: 0px;
	     text-shadow: none;
	     display: inline-block;
	     text-align: start;
	     appearance: auto;
	     background-color: -internal-light-dark(rgb(255, 255, 255), rgb(59, 59, 59));
	     -webkit-rtl-ordering: logical;
	     flex-direction: column;
	     resize: auto;
	     cursor: text;
	     white-space: pre-wrap;
	     overflow-wrap: break-word;
	     column-count: initial !important;
	     margin: 0em;
	     font: 400 13.3333px Arial;
	     border-width: 1px;
	     border-style: solid;
	     border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
	     border-image: initial;
	     padding: 2px;
	     border-radius: 2px;
	 }
	 
	 .layui-form-item {
	     margin-bottom: 15px;
	     clear: both;
	     *zoom: 1;
		 margin: -5px;
		 padding: 0;
		 -webkit-tap-highlight-color: rgba(0,0,0,0);
		 display: block;
	 }
	 .layui-col-md6{
		 position: relative;
		 display: block;
		 box-sizing: border-box;
		 margin: 0;
		 padding: 0;
		 -webkit-tap-highlight-color: rgba(0,0,0,0);
	 }
	 .layui-form-label {
	     float: left;
	     display: block;
	     padding: 9px 15px;
	     width: 80px;
	     font-weight: 400;
	     text-align: right;
		 line-height: 20px;
		 position: relative;
	 }
	 .layui-input-block {
	     margin-left: 110px;
	     min-height: 36px;
		 position: relative;
		 margin: 0;
		 padding: 0;
		 -webkit-tap-highlight-color: rgba(0,0,0,0);
		 display: block;
	 }
	 .layui-col-space10>* {
	     padding: 5px;
	 }
	 input{
	     -webkit-writing-mode: horizontal-tb !important;
	     text-rendering: auto;
	     color: -internal-light-dark(black, white);
	     letter-spacing: normal;
	     word-spacing: normal;
	     text-transform: none;
	     text-indent: 0px;
	     text-shadow: none;
	     display: inline-block;
	     text-align: start;
	     appearance: auto;
	     background-color: -internal-light-dark(rgb(255, 255, 255), rgb(59, 59, 59));
	     -webkit-rtl-ordering: logical;
	     cursor: text;
	     margin: 0em;
	     font: 400 13.3333px Arial;
	     padding: 1px 2px;
	     border-width: 2px;
	     border-style: inset;
	     border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
	     border-image: initial;
	     border-radius: 2px;
	 }
	 .layui-form-checkbox i {
	     position: absolute;
	     right: 0;
	     width: 30px;
	     color: #fff;
	     font-size: 20px;
	     text-align: center;
	 }
	 .layui-icon {
	     font-family: layui-icon!important;
	     font-size: 16px;
	     font-style: normal;
	     -webkit-font-smoothing: antialiased;
	     -moz-osx-font-smoothing: grayscale;
	 }
	 .layui-btn{
		     display: inline-block;
		     height: 38px;
		     line-height: 38px;
		     padding: 0 18px;
		     background-color: #009688;
		     color: #fff;
		     white-space: nowrap;
		     text-align: center;
		     font-size: 14px;
		     border: none;
		     border-radius: 2px;
		     cursor: pointer;
		     -moz-user-select: none;
		     -webkit-user-select: none;
		     -ms-user-select: none;
	 }
	 .layui-form-item .layui-inline {
	     margin-bottom: 5px;
	     margin-right: 10px;
	 }
	 .ssecc-show {
	     border: solid 1px #d2d2d2;
	     padding: 10px;
	     text-align: left;
	     color: #333;
		 margin: 0;
		 padding: 0;
		 -webkit-tap-highlight-color: rgba(0,0,0,0);
	 }
	 pre {
	     white-space: pre-wrap;
	     white-space: -moz-pre-wrap;
	     white-space: -pre-wrap;
	     white-space: -o-pre-wrap;
	     word-wrap: break-word;
		 margin: 0;
		 padding: 0;
		 -webkit-tap-highlight-color: rgba(0,0,0,0);
	 }
    a.item-header{
        color: #009688;
    }
    .load{
        margin-top: 20px;
    }
    .ssecc-show{
        border:solid 1px #d2d2d2;
        padding:10px;
        text-align:left;
        color:#333;
    }
    .error-show{
        display: none;
    }
  </style>
</head>
<body>
<div class="layui-container" style="margin-top:70px;min-height:100%">
	<div class="layui-row">
			<div class="layui-col-md4">
			<fieldset class="layui-elem-field layui-field-title" style="margin:10px 0 0;">
				<legend class="ctf_zhong_biaoti"><h4>JJencode</h4></legend>
			</fieldset>
			</div>
			<div class="layui-col-md8"></div>
		</div>
		<div class="layui-row" style="margin-top:10px;">
				<div class="layui-col-md12">
					<span style="color:#777">JJencode编码/JJencode解码</span>
				</div>
			</div>
	<div class="layui-row">
			<div class="layui-form">
					<div class="layui-form-item layui-form-text">
							<pre style="margin-bottom:-20px;">
							  <textarea placeholder="输入待编解码内容，不支持中文" name="text" id="content" class="layui-textarea" style="height:250px;">
alert("Hello, JavaScript")
							  </textarea>
							</pre>
						  </div>
						  <div class="layui-form-item layui-row layui-col-space10" style="margin-bottom:20px;">
							<div class="layui-col-md6">
									<label class="layui-form-label" style="color:#777">全局变量：</label>
									<div class="layui-input-block">
									  <input type="text" name="title" class="layui-input" value="$" id="var">
									</div>
							</div>
							<div class="layui-col-md6" style="text-align:center">回文（顺读和倒读都一样）
								<input type="checkbox" name="punct" title="Palindrome" lay-skin="primary" id="palindrome">
							</div>
						</div>
					<div class="layui-form-item" style="text-align:center;margin-bottom:-5px;">
						<div class="layui-inline">
							<div class="layui-input-block">
								<button class="layui-btn" type="button" id="jj_jiami" onclick="javascript:encryption();">加&nbsp;&nbsp;密</button>
							</div>
						</div>
						<div class="layui-inline">
							<div class="layui-input-block">
								<button class="layui-btn" type="button" id="jj_jiemi" onclick="javascript:decrypt();">解&nbsp;&nbsp;密</button>
							</div>
						</div>
					</div>
				</form>
	</div>
	<div class="load">
		<div class="ssecc-show error-show" id="jj_result"><pre id="dst"></pre></div>
	</div>
</div>
<script>
		function encryption(){
			var t = document.getElementById( "content" ).value;
			if(t==""){
				document.getElementById("dst").innerHTML ="不能为空！";
			}else{
				var show=encode_jj(true);
				document.getElementById("jj_result").classList.remove("error-show");
				document.getElementById("dst").innerHTML = show;
			}
		}
		function decrypt(){
			var t = document.getElementById( "content" ).value;
			if(t==""){
				document.getElementById("dst").innerHTML ="不能为空！";
			}else{
				document.getElementById("jj_result").classList.remove("error-show");
				jjdecode();
			}
		}

		////////JJ加密
		function jjencode( gv, text )
		{
		    var r="";
		    var n;
		    var t;
		    var b=[ "___", "__$", "_$_", "_$$", "$__", "$_$", "$$_", "$$$", "$___", "$__$", "$_$_", "$_$$", "$$__", "$$_$", "$$$_", "$$$$", ];
		    var s = "";
		    for( var i = 0; i < text.length; i++ ){
		        n = text.charCodeAt( i );
		        if( n == 0x22 || n == 0x5c ){
		            s += "\\\\\\" + text.charAt( i ).toString(16);
		        }else if( (0x21 <= n && n <= 0x2f) || (0x3A <= n && n <= 0x40) || ( 0x5b <= n && n <= 0x60 ) || ( 0x7b <= n && n <= 0x7f ) ){
		        //}else if( (0x20 <= n && n <= 0x2f) || (0x3A <= n == 0x40) || ( 0x5b <= n && n <= 0x60 ) || ( 0x7b <= n && n <= 0x7f ) ){
		            s += text.charAt( i );
		        }else if( (0x30 <= n && n <= 0x39 ) || (0x61 <= n && n <= 0x66 ) ){
		            if( s ) r += "\"" + s +"\"+";
		            r += gv + "." + b[ n < 0x40 ? n - 0x30 : n - 0x57 ] + "+";
		            s="";
		        }else if( n == 0x6c ){ // 'l'
		            if( s ) r += "\"" + s + "\"+";
		            r += "(![]+\"\")[" + gv + "._$_]+";
		            s = "";
		        }else if( n == 0x6f ){ // 'o'
		            if( s ) r += "\"" + s + "\"+";
		            r += gv + "._$+";
		            s = "";
		        }else if( n == 0x74 ){ // 'u'
		            if( s ) r += "\"" + s + "\"+";
		            r += gv + ".__+";
		            s = "";
		        }else if( n == 0x75 ){ // 'u'
		            if( s ) r += "\"" + s + "\"+";
		            r += gv + "._+";
		            s = "";
		        }else if( n < 128 ){
		            if( s ) r += "\"" + s;
		            else r += "\"";
		            r += "\\\\\"+" + n.toString( 8 ).replace( /[0-7]/g, function(c){ return gv + "."+b[ c ]+"+" } );
		            s = "";
		        }else{
		            if( s ) r += "\"" + s;
		            else r += "\"";
		            r += "\\\\\"+" + gv + "._+" + n.toString(16).replace( /[0-9a-f]/gi, function(c){ return gv + "."+b[parseInt(c,16)]+"+"} );
		            s = "";
		        }
		    }
		    if( s ) r += "\"" + s + "\"+";
		
		    r = 
		    gv + "=~[];" + 
		    gv + "={___:++" + gv +",$$$$:(![]+\"\")["+gv+"],__$:++"+gv+",$_$_:(![]+\"\")["+gv+"],_$_:++"+
		    gv+",$_$$:({}+\"\")["+gv+"],$$_$:("+gv+"["+gv+"]+\"\")["+gv+"],_$$:++"+gv+",$$$_:(!\"\"+\"\")["+
		    gv+"],$__:++"+gv+",$_$:++"+gv+",$$__:({}+\"\")["+gv+"],$$_:++"+gv+",$$$:++"+gv+",$___:++"+gv+",$__$:++"+gv+"};"+
		    gv+".$_="+
		    "("+gv+".$_="+gv+"+\"\")["+gv+".$_$]+"+
		    "("+gv+"._$="+gv+".$_["+gv+".__$])+"+
		    "("+gv+".$$=("+gv+".$+\"\")["+gv+".__$])+"+
		    "((!"+gv+")+\"\")["+gv+"._$$]+"+
		    "("+gv+".__="+gv+".$_["+gv+".$$_])+"+
		    "("+gv+".$=(!\"\"+\"\")["+gv+".__$])+"+
		    "("+gv+"._=(!\"\"+\"\")["+gv+"._$_])+"+
		    gv+".$_["+gv+".$_$]+"+
		    gv+".__+"+
		    gv+"._$+"+
		    gv+".$;"+
		    gv+".$$="+
		    gv+".$+"+
		    "(!\"\"+\"\")["+gv+"._$$]+"+
		    gv+".__+"+
		    gv+"._+"+
		    gv+".$+"+
		    gv+".$$;"+
		    gv+".$=("+gv+".___)["+gv+".$_]["+gv+".$_];"+
		    gv+".$("+gv+".$("+gv+".$$+\"\\\"\"+" + r + "\"\\\"\")())();";
		    return r;
		}
		var _prev;
		
		function encode_jj( force )
		{
		    var t = document.getElementById( "content" ).value;
		    var v = document.getElementById( "var" ).value || "$";
			var p = document.getElementById( "palindrome" ).checked;
			var r;
		
		    if( _prev != ( t + "\0" + v + "\0" + p ) || force ){
				r = jjencode( v, t );
				if( p ){
					r = r.replace( /[,;]$/, "" );
					r = "\"\'\\\"+\'+\"," + r + ",\'," + r.split("").reverse().join("") +",\"+\'+\"\\\'\"";
				}
		    }
		    return r
		}
//==========================================================================
		        function cls()
		        {
		            document.getElementById("dst").innerHTML = '';
		        }
		
		        function out(c)
		        {
		            var d = document.getElementById("dst").innerHTML;
		            document.getElementById("dst").innerHTML = d + c;
		        }
		////////JJ解密
		        function jjdecode()
		        {
		            cls();
		            
		            //get string from src
		            var t = document.getElementById("content").value;
		            
		            //clean it
		            t.replace(/^\s+|\s+$/g, "");
		            
		            var startpos;
		            var endpos;
		            var gv;
		            var  gvl;	
		            
		            if (t.indexOf("\"\'\\\"+\'+\",") == 0) //palindrome check
		            {
		                //locate jjcode
		                startpos	= t.indexOf('$$+"\\""+') + 8;
		                endpos		= t.indexOf('"\\"")())()');
		                    
		                //get gv
		                gv	= t.substring((t.indexOf('"\'\\"+\'+",')+9), t.indexOf("=~[]"));
		                gvl	= gv.length;
		            }
		            else
		            {
		                //get gv
		                gv	= t.substr(0, t.indexOf("="));
		                gvl	= gv.length;
		                
		                //locate jjcode
		                startpos	= t.indexOf('"\\""+') + 5;
		                endpos		= t.indexOf('"\\"")())()');	
		            }
		                        
		            if (startpos == endpos)
		            {
		                alert("No data !");
		                return;
		            }
		            
		            //start decoding
		            var data = t.substring(startpos, endpos);
		                
		            //hex decode string
		            var b=[ "___+", "__$+", "_$_+", "_$$+", "$__+", "$_$+", "$$_+", "$$$+", "$___+", "$__$+", "$_$_+", "$_$$+", "$$__+", "$$_$+", "$$$_+", "$$$$+" ];
		            
		            //lotu
		            var str_l = "(![]+\"\")[" + gv + "._$_]+";
		            var str_o = gv + "._$+";
		            var str_t = gv + ".__+";
		            var str_u = gv + "._+";
		            
		            //0123456789abcdef
		            var str_hex = gv + ".";
		            
		            //s
		            var str_s = '"';
		            var gvsig = gv + ".";
		            
		            var str_quote = '\\\\\\"';
		            var str_slash = '\\\\\\\\';
		            
		            var str_lower = "\\\\\"+";
		            var str_upper = "\\\\\"+" + gv + "._+";
		            
		            var str_end	= '"+'; //end of s loop
		            
		            
		            
		            while(data != "")
		            {
		                //l o t u
		                if (0 == data.indexOf(str_l))
		                {
		                    data = data.substr(str_l.length);
		                    out("l");
		                    continue;
		                }
		                else if (0 == data.indexOf(str_o))
		                {
		                    data = data.substr(str_o.length);
		                    out("o");
		                    continue;
		                }
		                else if (0 == data.indexOf(str_t))
		                {
		                    data = data.substr(str_t.length);
		                    out("t");
		                    continue;
		                }
		                else if (0 == data.indexOf(str_u))
		                {
		                    data = data.substr(str_u.length);
		                    out("u");
		                    continue;
		                }
		                
		                //0123456789abcdef
		                if (0 == data.indexOf(str_hex))
		                {
		                    data = data.substr(str_hex.length);
		                    
		                    //check every element of hex decode string for a match 
		                    var i = 0;						
		                    for (i = 0; i < b.length; i++)
		                    {
		                        if (0 == data.indexOf(b[i]))
		                        {
		                            data = data.substr( (b[i]).length );
		                            out(i.toString(16));
		                            break;
		                        }
		                    }
		                    continue;
		                }
		                
		                //start of s block
		                if (0 == data.indexOf(str_s))
		                {
		                    data = data.substr(str_s.length);
		                    
		                    //check if "R
		                    if (0 == data.indexOf(str_upper)) // r4 n >= 128
		                    {
		                        data = data.substr(str_upper.length); //skip sig
		                        
		                        var ch_str = "";				
		                        for (j = 0; j < 2; j++) //shouldn't be more than 2 hex chars
		                        {
		                            //gv + "."+b[ c ]				
		                            if (0 == data.indexOf(gvsig))
		                            {
		                                data = data.substr(gvsig.length); //skip gvsig	
		
		                                for (k = 0; k < b.length; k++)	//for every entry in b
		                                {						
		                                    if (0 == data.indexOf(b[k]))
		                                    {
		                                        data = data.substr(b[k].length);
		                                        ch_str += k.toString(16) + "";							
		                                        break;
		                                    }
		                                }						
		                            }
		                            else
		                            {
		                                break; //done
		                            }								
		                        }
		                        
		                        out(String.fromCharCode(parseInt(ch_str,16)));
		                        continue;
		                    }
		                    else if (0 == data.indexOf(str_lower)) //r3 check if "R // n < 128
		                    {
		                        data = data.substr(str_lower.length); //skip sig
		                        
		                        var ch_str = "";
		                        var ch_lotux = ""
		                        var temp = "";
		                        var b_checkR1 = 0;
		                        for (j = 0; j < 3; j++) //shouldn't be more than 3 octal chars
		                        {
		                        
		                            if (j > 1) //lotu check
		                            {								
		                                if (0 == data.indexOf(str_l))
		                                {
		                                    data = data.substr(str_l.length);
		                                    ch_lotux = "l";
		                                    break;
		                                }
		                                else if (0 == data.indexOf(str_o))
		                                {
		                                    data = data.substr(str_o.length);
		                                    ch_lotux = "o";
		                                    break;
		                                }
		                                else if (0 == data.indexOf(str_t))
		                                {
		                                    data = data.substr(str_t.length);
		                                    ch_lotux = "t";
		                                    break;
		                                }
		                                else if (0 == data.indexOf(str_u))
		                                {
		                                    data = data.substr(str_u.length);
		                                    ch_lotux = "u";
		                                    break;
		                                }						
		                            }
		                        
		                            //gv + "."+b[ c ]							
		                            if (0 == data.indexOf(gvsig))
		                            {
		                                temp = data.substr(gvsig.length); 
		                                for (k = 0; k < 8; k++)	//for every entry in b octal
		                                {						
		                                    if (0 == temp.indexOf(b[k]))
		                                    {
		                                        if (parseInt(ch_str + k + "",8) > 128)
		                                        {
		                                            b_checkR1 = 1;
		                                            break;
		                                        }								
		                                        
		                                        ch_str += k + "";										
		                                        data = data.substr(gvsig.length); //skip gvsig
		                                        data = data.substr(b[k].length);
		                                        break;
		                                    }
		                                }
		                                
		                                if (1 == b_checkR1)
		                                {
		                                    if (0 == data.indexOf(str_hex)) //0123456789abcdef
		                                    {
		                                        data = data.substr(str_hex.length);
		                                        
		                                        //check every element of hex decode string for a match 
		                                        var i = 0;						
		                                        for (i = 0; i < b.length; i++)
		                                        {
		                                            if (0 == data.indexOf(b[i]))
		                                            {
		                                                data = data.substr( (b[i]).length );
		                                                ch_lotux = i.toString(16);
		                                                break;
		                                            }
		                                        }
		                                        
		                                        break;
		                                    }
		                                }								
		                            }
		                            else
		                            {								
		                                break; //done
		                            }								
		                        }
		
		                        out(String.fromCharCode(parseInt(ch_str,8)) + ch_lotux);
		                        continue; //step out of the while loop
		                    }
		                    else //"S ----> "SR or "S+
		                    {
		                        
		                        // if there is, loop s until R 0r +
		                        // if there is no matching s block, throw error
		                        
		                        var match = 0;
		                        var n;
		
		                        //searching for mathcing pure s block
		                        while(true)
		                        {
		                            n = data.charCodeAt( 0 );				
		                            if (0 == data.indexOf(str_quote))
		                            {
		                                data = data.substr(str_quote.length);
		                                out('"');
		                                match += 1;
		                                continue;
		                            }
		                            else if (0 == data.indexOf(str_slash))
		                            {
		                                data = data.substr(str_slash.length);
		                                out('\\');
		                                match += 1;
		                                continue;
		                            }
		                            else if (0 == data.indexOf(str_end))	//reached end off S block ? +
		                            {
		                                if (match == 0)
		                                {
		                                    alert("+ no match S block: "+data);
		                                    return;
		                                }
		                                data = data.substr(str_end.length);
		                                
		                                break; //step out of the while loop
		                            }
		                            else if (0 == data.indexOf(str_upper)) //r4 reached end off S block ? - check if "R n >= 128
		                            {						
		                                if (match == 0)
		                                {
		                                    alert("no match S block n>128: "+data);
		                                    return;
		                                }
		                            
		                                data = data.substr(str_upper.length); //skip sig
		                                
		                                var ch_str = "";
		                                var ch_lotux = "";
		                                for (j = 0; j < 10; j++) //shouldn't be more than 10 hex chars
		                                {
		                                
		                                    if (j > 1) //lotu check
		                                    {								
		                                        if (0 == data.indexOf(str_l))
		                                        {
		                                            data = data.substr(str_l.length);
		                                            ch_lotux = "l";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_o))
		                                        {
		                                            data = data.substr(str_o.length);
		                                            ch_lotux = "o";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_t))
		                                        {
		                                            data = data.substr(str_t.length);
		                                            ch_lotux = "t";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_u))
		                                        {
		                                            data = data.substr(str_u.length);
		                                            ch_lotux = "u";
		                                            break;
		                                        }
		                                    }
		                                
		                                    //gv + "."+b[ c ]				
		                                    if (0 == data.indexOf(gvsig))
		                                    {
		                                        data = data.substr(gvsig.length); //skip gvsig
		
		                                        for (k = 0; k < b.length; k++)	//for every entry in b
		                                        {						
		                                            if (0 == data.indexOf(b[k]))
		                                            {
		                                                data = data.substr(b[k].length);
		                                                ch_str += k.toString(16) + "";							
		                                                break;
		                                            }
		                                        }						
		                                    }
		                                    else
		                                    {
		                                        break; //done
		                                    }								
		                                }
		                                
		                                out(String.fromCharCode(parseInt(ch_str,16)));
		                                break; //step out of the while loop
		                            }
		                            else if (0 == data.indexOf(str_lower)) //r3 check if "R // n < 128
		                            {
		                                if (match == 0)
		                                {
		                                    alert("no match S block n<128: "+data);
		                                    return;
		                                }
		                            
		                                data = data.substr(str_lower.length); //skip sig
		                                
		                                var ch_str = "";
		                                var ch_lotux = ""
		                                var temp = "";
		                                var b_checkR1 = 0;
		                                for (j = 0; j < 3; j++) //shouldn't be more than 3 octal chars
		                                {
		                                
		                                    if (j > 1) //lotu check
		                                    {								
		                                        if (0 == data.indexOf(str_l))
		                                        {
		                                            data = data.substr(str_l.length);
		                                            ch_lotux = "l";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_o))
		                                        {
		                                            data = data.substr(str_o.length);
		                                            ch_lotux = "o";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_t))
		                                        {
		                                            data = data.substr(str_t.length);
		                                            ch_lotux = "t";
		                                            break;
		                                        }
		                                        else if (0 == data.indexOf(str_u))
		                                        {
		                                            data = data.substr(str_u.length);
		                                            ch_lotux = "u";
		                                            break;
		                                        }								
		                                    }
		                                
		                                    //gv + "."+b[ c ]							
		                                    if (0 == data.indexOf(gvsig))
		                                    {
		                                        temp = data.substr(gvsig.length); 
		                                        for (k = 0; k < 8; k++)	//for every entry in b octal
		                                        {						
		                                            if (0 == temp.indexOf(b[k]))
		                                            {
		                                                if (parseInt(ch_str + k + "",8) > 128)
		                                                {
		                                                    b_checkR1 = 1;
		                                                    break;
		                                                }								
		                                                
		                                                ch_str += k + "";										
		                                                data = data.substr(gvsig.length); //skip gvsig
		                                                data = data.substr(b[k].length);
		                                                break;
		                                            }
		                                        }
		                                        
		                                        if (1 == b_checkR1)
		                                        {
		                                            if (0 == data.indexOf(str_hex)) //0123456789abcdef
		                                            {
		                                                data = data.substr(str_hex.length);
		                                                
		                                                //check every element of hex decode string for a match 
		                                                var i = 0;						
		                                                for (i = 0; i < b.length; i++)
		                                                {
		                                                    if (0 == data.indexOf(b[i]))
		                                                    {
		                                                        data = data.substr( (b[i]).length );
		                                                        ch_lotux = i.toString(16);
		                                                        break;
		                                                    }
		                                                }
		                                            }
		                                        }								
		                                    }
		                                    else
		                                    {								
		                                        break; //done
		                                    }								
		                                }
		
		                                out(String.fromCharCode(parseInt(ch_str,8)) + ch_lotux);
		                                break; //step out of the while loop
		                            }	 
		                            else if( (0x21 <= n && n <= 0x2f) || (0x3A <= n && n <= 0x40) || ( 0x5b <= n && n <= 0x60 ) || ( 0x7b <= n && n <= 0x7f ) )
		                            {
		                                out(data.charAt( 0 ));
		                                data = data.substr( 1 );
		                                match += 1;
		                            }
		                            
		                        }			
		                        continue;			
		                    }
		                }
		                    
		                alert("no match : "+data);
		                break;
		            }
		              
		        }
		
	</script>

</body>
</html>